All Questions
19 questions
1vote
4answers
367views
Insert one file's content into another file and replace it between pattern
I have a file1.html: <!doctype html> <html> <head> </head> <body> text <!-- start-replacing --> <p>more text1</p> <p>more text2</p> ...
3votes
5answers
415views
Replace empty lines in one file with lines from another file
I have file1.csv "word 1" "" "word 3" "" "word 5" "word 6" and file2.csv "replacement text 1" "replacement text 2" &...
0votes
1answer
187views
Find and replace everything inside bracket using unix shell - several lines
I need to find and replace a big part of a json file using shell. For exemple I have this file : { "Balise1": true, "Balise2": true, "OtherThingEnabled": false, ...
1vote
2answers
166views
sed -Extended RegEx question here
I feel dumb as a sack of hammers asking this here, but it's been a long day and I simply CANNOT figure out what I'm doing wrong here. I have a file; we'll call it textfile.txt. It's contents are (in ...
0votes
1answer
1kviews
Output remote hostname in sshpass session
I have created a shell script to connect to a list of servers using sshpass and run a list of about 30 commands. An extract of the script is below. The script will wget a new config file, but then I ...
0votes
1answer
217views
Extracting multiple strings, according to a pattern, in a bash script
I'm writing a shell script to generate a directory listing. as an input a receive a long html string : https://www.mycompany.com/posts/aureliaflore_china-seoul-startup-activity-6571925510337728512-...
2votes
3answers
1kviews
Loop over numbered files and append on every line of file the content of another file with the same number
I have a lot of numbered *.csv files with different numbers of lines and just as many *.txt files. I want to append on every line of file 1.csv the content of file 1.txt, on every line of file 2.csv ...
1vote
0answers
59views
Two replacements in one go [duplicate]
How do I go about replacing one character for another and then another character for another in one line and printing the result? As an example, consider the following code: string="1 33 4 a" echo ${...
0votes
3answers
98views
How to replace a number by its corresponding string (low/high) in bash?
I have a file: property(Address1, 4.5) property(Address2, 2.2) property(Address3, 9.0) property(Address4, 3.4) --- I want to replace the floating points based on some conditions (For example: if the ...
1vote
4answers
2kviews
Removing part of all file name in a folder?
My camera stores photos in the following format: DSC_0001 (2015_07_30 10_34_56 UTC).NEF With the number after DSC_ iterating, and the brackets specifying the time and date, however all the time and ...
0votes
1answer
2kviews
replace unix variable with value into sql file
I have sql file with multiple unix variable to spool the log into specific location and need to replace the unix variable with actual path before running sql file `cat a.sql accept v_answer prompt "...
2votes
3answers
554views
Replace a dynamic file extension with a fixed file extension
I need to replace dynamic file extensions which contain timestamp for certain date with a fixed file extension. For example, 08242016G0040156.ZIP.20160907141452 09042016SHOC0003.ZIP....
6votes
4answers
18kviews
bash / sh script to replace text between some tags/strings in a text file
I am creating executable which will be executed with /bin/sh or /bin/bash script, I have a file which contains a structure like, there will be only one #start and #end tag in the config file, and I ...
0votes
2answers
137views
If filename has more than n characters, delete the last ones
I'm kinda new with the unix shell, and I don't seem to find the answer of my problem : I have a folder containing multiple files : a correct filename contains exactly 13 characters (numbers + letters ...
0votes
1answer
83views
Can you replace displayed text with something else in command window?
I am trying to manage user accounts. They are basically just numbers, but I would rather see user last names on the screen. Is it possible to automatically replace displayed text with something else? ...